package com.software.levelupserver.entity;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

public class SecurityUserDetails implements UserDetails {

    private final User user;
    private List<SimpleGrantedAuthority> authorities;

    public SecurityUserDetails(User user) {
        this.user = user;
    }


    public void setAuthorities(List<SimpleGrantedAuthority> authorities) {
        this.authorities = authorities;
    }

    @Override
    public String getPassword() {
        return user.getPassword();
    }
    @Override
    public String getUsername() {
        return user.getUsername();
    }

    public User getUser() {
        return user;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

//    @Override
//    public boolean isAccountNonExpired() {
//        return user.getAccountNoExpired()==1?true:false;
//    }
//
//    @Override
//    public boolean isAccountNonLocked() {
//        return user.getAccountNoLocked()==1?true:false;
//    }
//
//    @Override
//    public boolean isCredentialsNonExpired() {
//        return user.getCredentialsNoExpired()==1?true:false;
//    }
//
//    @Override
//    public boolean isEnabled() {
//        return user.getEnabled()==1?true:false;
//    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
